jQuery(document).ready(function(){
	jQuery('.upcoming-event-time').each(function(){
		var wrapper = jQuery(this).children('a');
		
		var day_field = wrapper.children('.upcoming-event-day').children('span');
		var day = parseInt(day_field.text());
		
		var hour_field = wrapper.children('.upcoming-event-hour').children('span');
		var hour = parseInt(hour_field.text());
		
		var minute_field = wrapper.children('.upcoming-event-minute').children('span');
		var minute = parseInt(minute_field.text());
		
		var second_field = wrapper.children('.upcoming-event-second').children('span');
		var second = parseInt(second_field.text());

		var i = setInterval(function(){
			if( second > 0 ){
				second--;			
			}else{
				second = 59;
				if( minute > 0 ){
					minute--;
				}else{
					minute = 59;
					if( hour > 0 ){
						hour--;
					}else{
						hour = 24;
						if( day > 0 ){
							day--;
						}else{
							day = 0;
							hour = 0;
							minute = 0;
							second = 0;
							clearInterval(i);
						}
					}
				}
				minute_field.text(minute);
			}
			second_field.text(second);	
		}, 1000);
	});
	
	
});